package InterfaceMahasiswa;

import InterfaceStaff.*;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.*;
import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel;
import tools.QRReader;

public class FormPresensi extends javax.swing.JFrame {

    private void MatikanTombol() {
        NIM.setEditable(false);
        NamaScan.setEditable(false);
        hadir.setEditable(false);
        thadir.setEditable(false);
        total.setEditable(false);

    }

    public FormPresensi() {
        try {
            initComponents();
            List<Mahasiswa> kategori = (List<Mahasiswa>) Presensi.getKoneksi().getAll();
            PresensiModel model = new PresensiModel(kategori);
            TKategori.setModel(model);
        } catch (Exception e) {
            Logger.getLogger(FormPresensi.class.getName()).log(Level.SEVERE, null, e);
        }
        getComboboxMakul();
        getCombobox();
        setTitle("Form Presensi");
        setResizable(false);
        NIM.requestFocus();
        MatikanTombol();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jPopupMenu1 = new javax.swing.JPopupMenu();
        jPopupMenu2 = new javax.swing.JPopupMenu();
        jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
        jCheckBoxMenuItem2 = new javax.swing.JCheckBoxMenuItem();
        popupMenu1 = new java.awt.PopupMenu();
        jLabel3 = new javax.swing.JLabel();
        namaMhs = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        TKategori = new javax.swing.JTable();
        jPanel5 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        NIM = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        NamaScan = new javax.swing.JTextField();
        jPanel6 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        ok = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        makul = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        pengampu = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        hadir = new javax.swing.JTextField();
        thadir = new javax.swing.JTextField();
        total = new javax.swing.JTextField();
        Cari = new javax.swing.JButton();

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        jCheckBoxMenuItem1.setSelected(true);
        jCheckBoxMenuItem1.setText("jCheckBoxMenuItem1");

        jCheckBoxMenuItem2.setSelected(true);
        jCheckBoxMenuItem2.setText("jCheckBoxMenuItem2");

        popupMenu1.setLabel("popupMenu1");

        jLabel3.setText("Nama Kategori");

        namaMhs.setToolTipText("Isikan Nama Kategori");
        namaMhs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                namaMhsActionPerformed(evt);
            }
        });

        jButton1.setText("jButton1");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(153, 153, 255));

        jPanel3.setBackground(new java.awt.Color(204, 204, 255));
        jPanel3.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 255, 102), 1, true));
        jPanel3.setForeground(new java.awt.Color(102, 255, 102));

        TKategori.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        TKategori.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "NIM", "Nama", "Status"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, false, true
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        TKategori.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                TKategoriMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(TKategori);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 553, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel5.setBackground(new java.awt.Color(153, 153, 255));

        jLabel2.setFont(new java.awt.Font("MS UI Gothic", 0, 18));
        jLabel2.setText("NIM");

        NIM.setToolTipText("Isikan Kode Kategori");
        NIM.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                NIMMouseClicked(evt);
            }
        });
        NIM.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NIMActionPerformed(evt);
            }
        });
        NIM.addInputMethodListener(new java.awt.event.InputMethodListener() {
            public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
            }
            public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
                NIMInputMethodTextChanged(evt);
            }
        });
        NIM.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                NIMPropertyChange(evt);
            }
        });
        NIM.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                NIMKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                NIMKeyTyped(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("MS Gothic", 0, 18));
        jLabel5.setText("Nama");

        NamaScan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NamaScanActionPerformed(evt);
            }
        });

        jPanel6.setBackground(new java.awt.Color(204, 204, 255));

        jLabel4.setBackground(new java.awt.Color(102, 255, 102));
        jLabel4.setFont(new java.awt.Font("Gabriola", 1, 48));
        jLabel4.setForeground(new java.awt.Color(51, 0, 255));
        jLabel4.setText("SMART PRESENSI");
        jPanel6.add(jLabel4);

        jLabel11.setFont(new java.awt.Font("Vijaya", 2, 24));
        jLabel11.setForeground(new java.awt.Color(51, 51, 255));
        jLabel11.setText("Universitas Sanata Dharma");
        jPanel6.add(jLabel11);

        ok.setText("OK");
        ok.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(350, 350, 350)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(NIM, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE))
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(NamaScan)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(ok)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel2)
                            .addComponent(NIM, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(NamaScan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(ok)))
                .addGap(52, 52, 52))
        );

        NIM.getAccessibleContext().setAccessibleDescription("NIM Mahasiswa Hadir");
        NamaScan.getAccessibleContext().setAccessibleDescription("Nama Mahasiswa Hadir");

        jPanel1.setBackground(new java.awt.Color(204, 204, 255));

        jLabel6.setFont(new java.awt.Font("MS UI Gothic", 0, 18));
        jLabel6.setText("Mata Kuliah");

        makul.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                makulActionPerformed(evt);
            }
        });

        jLabel7.setFont(new java.awt.Font("MS Gothic", 0, 18));
        jLabel7.setText("Pengampu");

        jLabel8.setFont(new java.awt.Font("MS UI Gothic", 0, 18));
        jLabel8.setText("Hadir");

        jLabel9.setFont(new java.awt.Font("MS UI Gothic", 0, 18));
        jLabel9.setText("Tidak Hadir");

        jLabel10.setFont(new java.awt.Font("MS Gothic", 0, 18));
        jLabel10.setText("Total Mahasiswa");

        total.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                totalActionPerformed(evt);
            }
        });

        Cari.setText("Open");
        Cari.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CariActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7)
                    .addComponent(jLabel9)
                    .addComponent(jLabel8)
                    .addComponent(jLabel10))
                .addGap(51, 51, 51)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(pengampu, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(makul, javax.swing.GroupLayout.Alignment.LEADING, 0, 49, Short.MAX_VALUE))
                        .addGap(52, 52, 52)
                        .addComponent(Cari))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(total, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(hadir, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(thadir, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 27, Short.MAX_VALUE)))
                .addContainerGap(219, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(makul, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(pengampu, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(40, 40, 40)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(hadir, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(thadir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel10)
                            .addComponent(total, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(Cari)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addComponent(jLabel1))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(50, 50, 50)
                        .addComponent(jLabel1))
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void namaMhsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_namaMhsActionPerformed
    }//GEN-LAST:event_namaMhsActionPerformed

    private void NIMKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_NIMKeyTyped
//        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
//            namaMhs.requestFocus();
//        }

    }//GEN-LAST:event_NIMKeyTyped

    private void NIMActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NIMActionPerformed
    }//GEN-LAST:event_NIMActionPerformed

    private void TKategoriMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TKategoriMouseClicked
    }//GEN-LAST:event_TKategoriMouseClicked

    private void NIMMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_NIMMouseClicked

        MatikanTombol();
    }//GEN-LAST:event_NIMMouseClicked

    private void NIMKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_NIMKeyReleased
    }//GEN-LAST:event_NIMKeyReleased

    private void makulActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_makulActionPerformed
    }//GEN-LAST:event_makulActionPerformed

    private void CariActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CariActionPerformed

        String txtCombo = (String) makul.getSelectedItem();
        MataKuliah mk = new MataKuliah();
        mk.setMakul(txtCombo);

        String txtCombo2 = (String) pengampu.getSelectedItem();
        Pengampu p = new Pengampu();
        p.setNama_pengampu(txtCombo2);

        TabelPresensi tp = new TabelPresensi();
        tp.setId_pengampu(p);
        tp.setId_matakuliah(mk);

        try {
            List<Mahasiswa> kategori = (List<Mahasiswa>) Presensi.getKoneksi().getAllCari(tp);
            PresensiModel model = new PresensiModel(kategori);
            TKategori.setModel(model);
        } catch (SQLException ex) {
            Logger.getLogger(FormPresensi.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_CariActionPerformed

    private void totalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_totalActionPerformed
    }//GEN-LAST:event_totalActionPerformed

    private void NIMPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_NIMPropertyChange
        NIM.setText(getNimb());
    }//GEN-LAST:event_NIMPropertyChange

    private void NIMInputMethodTextChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_NIMInputMethodTextChanged
    }//GEN-LAST:event_NIMInputMethodTextChanged

    private void NamaScanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NamaScanActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_NamaScanActionPerformed

    private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
//        QRReader qr = new QRReader();
//        hadir.setText("0");
//        NIM.setText(qr.getMkode().data);







    }//GEN-LAST:event_okActionPerformed

    private void refresh() {
        try {
            List<Mahasiswa> kategori = (List<Mahasiswa>) Presensi.getKoneksi().getAll();
            PresensiModel model = new PresensiModel(kategori);
            TKategori.setModel(model);
        } catch (Exception e) {
            Logger.getLogger(FormPresensi.class.getName()).log(Level.SEVERE, null, e);
        }
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    UIManager.setLookAndFeel(new MetalLookAndFeel());
                } catch (UnsupportedLookAndFeelException ex) {
                    Logger.getLogger(FormPresensi.class.getName()).log(Level.SEVERE, null, ex);
                }
                new FormPresensi().setVisible(true);
                tools.QRReader qr = new tools.QRReader();
                qr.createGraph();
            }
        });
    }

    public void getCombobox() {
        try {
            List<Pengampu> kategoris = Presensi.getKoneksi().getAllPengampu();
            for (Pengampu k : kategoris) {
                pengampu.addItem(k.getNama_pengampu());
            }
        } catch (Exception e) {
            Logger.getLogger(FormPresensi.class.getName()).log(Level.SEVERE, null, e);
        }
    }

    public void getComboboxMakul() {
        try {
            List<MataKuliah> kategoriss = Presensi.getKoneksi().getAllMakul();
            for (MataKuliah k : kategoriss) {
                makul.addItem(k.getMakul());
            }
        } catch (Exception e) {
            Logger.getLogger(FormPresensi.class.getName()).log(Level.SEVERE, null, e);
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Cari;
    private javax.swing.JTextField NIM;
    private javax.swing.JTextField NamaScan;
    private javax.swing.JTable TKategori;
    private javax.swing.JTextField hadir;
    private javax.swing.JButton jButton1;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JPopupMenu jPopupMenu2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JComboBox makul;
    private javax.swing.JTextField namaMhs;
    private javax.swing.JButton ok;
    private javax.swing.JComboBox pengampu;
    private java.awt.PopupMenu popupMenu1;
    private javax.swing.JTextField thadir;
    private javax.swing.JTextField total;
    // End of variables declaration//GEN-END:variables
    private String nimb;

    public String getMakul() {
        String matakuliah = (String) makul.getSelectedItem();
        return matakuliah;
    }

    public String getPengampu() {
        String pengampu2 = (String) pengampu.getSelectedItem();
        return pengampu2;
    }

    public String getNimb() {
        return nimb;
    }

    public void setNimb(String nimb) {
        this.nimb = nimb;
    }
}
